<template>
	<view class="roleSelection">
		<view class="roleSelection_item">首次使用，您的角色是</view>
		<view class="roleSelection_item1" @click="getcustomer">
			<image src="../../static/image/user/kehu.png" ></image>
			<view class="roleSelection_item1_demo" v-if="isShow" >
				<image src="../../static/image/user/xuanzhong.png"></image>
			</view>
			<view class="roleSelection_item1_demo" v-else >
				<image src="../../static/image/user/weixuanzhong.png"></image>
			</view>
		</view>
		<view class="roleSelection_item1" @click="getDesigner">
			<image src="../../static/image/user/shejishi.png"></image>
			<view class="roleSelection_item1_demo" v-if="isShow1" >
				<image src="../../static/image/user/xuanzhong.png"></image>
			</view>
			<view class="roleSelection_item1_demo" v-else>
				<image src="../../static/image/user/weixuanzhong.png"></image>
			</view>
		</view>
		<view class="roleSelection_item2" @click="getDesignerCertification">下一步</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isShow:true,
				isShow1:false,
				is_DC:''
			};
		},
		methods:{
			getcustomer(){
				// 客户端
				this.isShow=true;
				// 设计师端
				this.isShow1=false;
			},
			getDesigner(){
				// 客户端
				this.isShow=false;
				// 设计师端
				this.isShow1=true;
			},
			// 点击下一步跳转到设计师认证页面
			getDesignerCertification(){
				if(this.isShow==true){
					uni.reLaunch({
						url:'../homes/home/home'
					})
				}else{
					if(this.is_DC==1){
						uni.showModal({
							title:'提示',
							content:'您已经申请过设计师,是否跳转到首页',
							success:(res)=> {
								if(res.confirm){
									uni.reLaunch({
										url:'../mine/mine'
									})
								}
							}
						})
					}else if(this.is_DC==2){
						uni.showModal({
							title:'提示',
							content:'您已经是设计师,是否跳转到首页',
							success:(res)=> {
								if(res.confirm){
									uni.reLaunch({
										url:'../mine/mine'
									})
								}
							}
						})
					}else{
						uni.navigateTo({
							url:'../DesignerCertification/DesignerCertification'
						})
					}
					
				}
				
			},
			// 判断是否是设计师
			getDesigners(){
				this.$api.get({
					url: '/wanlshop/user/getDC',					
					success: res => {
						this.is_DC=res.is_DC;
						// 判断如果已经申请为设计师就直接跳转到首页
						console.log('设计师',res)
						if(res.is_DC==1){
							uni.showModal({
								title:'提示',
								content:'您已经申请过设计师,是否跳转到首页',
								success:(res)=> {
									if(res.confirm){
										uni.reLaunch({
											url:'../mine/mine'
										})
									}
								}
							})
						}else if(res.is_DC==2){
							uni.showModal({
								title:'提示',
								content:'您已经是设计师,是否跳转到首页',
								success:(res)=> {
									if(res.confirm){
										uni.reLaunch({
											url:'../mine/mine'
										})
									}
								}
							})
						}											
					}
				});
			}
		},
		onLoad() {
			this.getDesigners()
		}
	}
</script>

<style lang="scss">
.roleSelection{
	&_item{
		// background-color: pink;
		font-size: 30rpx;
		font-weight: bold;
		color: #4e4e4e;
		text-align: center;
		margin-top: 20rpx;
		margin-bottom: 150rpx;
	}
	&_item1{
		// background-color: pink;	
		position: relative;
		width: 600rpx;
		height: 250rpx;
		margin:0 auto 60rpx;
		image{
			width: 600rpx;
			height: 250rpx;
		}
		&_demo{
		position: absolute;
			right: 20rpx;
			bottom: 10rpx;
			image{
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
	&_item2{
		// background-color: pink;
		font-size: 30rpx;
		color: #4e4e4e;
		text-align: center;
		margin-top: 150rpx;
	}
}
</style>
